﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Com.Mapabc.Maps.Api.Layers;
using Com.Mapabc.Maps.Api.Enums;

namespace MapABCAPI_WP7.Samples
{
    public partial class AddLayer : PhoneApplicationPage
    {
        public AddLayer()
        {
            InitializeComponent();
        }
        /// <summary>
        /// 叠加/删除切片图层
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// 
        MTileLayer tilelayer = new MTileLayer(MTileLayerType.Traffic);
        MTileLayer transitlayer = new MTileLayer(MTileLayerType.MassTransit);
        private void TileLayer(object sender, GestureEventArgs e)
        {
            button1.Visibility = System.Windows.Visibility.Visible;
            button2.Visibility = System.Windows.Visibility.Visible;
            button3.Visibility = System.Windows.Visibility.Visible;
            button4.Visibility = System.Windows.Visibility.Visible;
            Pivot.SelectedIndex = 1;//显示效果
        }
        private void AddTileLayer(object sender, RoutedEventArgs e)
        {
            //叠加实时交通图层
            tilelayer.LayerId = "traffic";
            map.AddLayer(tilelayer);
        }

        private void RemoveTileLayer(object sender, RoutedEventArgs e)
        {
            //删除实时交通图层
            map.RemoveLayer(tilelayer);
        }

        private void AddTansitLayer(object sender, RoutedEventArgs e)
        {
            //叠加轨道交通图层
            transitlayer.LayerId = "transit";
            map.AddLayer(transitlayer);
        }

        private void RemoveTansitLayer(object sender, RoutedEventArgs e)
        {
            //删除轨道交通图层
            map.RemoveLayer(transitlayer);
        }

        private void Hidden()
        {
            button1.Visibility = System.Windows.Visibility.Collapsed;
            button2.Visibility = System.Windows.Visibility.Collapsed;
            button3.Visibility = System.Windows.Visibility.Collapsed;
            button4.Visibility = System.Windows.Visibility.Collapsed;
        }
        /// <summary>
        /// 重写后退键
        /// </summary>
        /// <param name="e"></param>
        protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
        {
            if (Pivot.SelectedIndex == 1)
            {
                e.Cancel = true;
                Pivot.SelectedIndex = 0;
            }
        }

       

    }
   
}